package game.breeze.util;

public class StringUtils {

	public static int[] toInteger(String obj, String separator) {
		if (isEmpty(obj)) {
			return new int[0];
		}
		String[] cols = obj.split(separator);
		int[] re = new int[cols.length];
		for (int i = 0; i < cols.length; i++) {
			re[i] = toInteger(cols[i]);
		}
		return re;
	}

	public static int toInteger(Object obj) {
		try {
			return Integer.valueOf(toString(obj));
		} catch (NumberFormatException e) {
			// e.printStackTrace();
		}
		return 0;
	}

	public static void replace(int[] src, int s, int e) {
		for (int i = s; i < e; i++) {
			src[i] = 0;
		}
	}

	public static String toString(Object obj) {
		return String.valueOf(obj);
	}

	public static boolean isEmpty(String obj) {
		return obj == null || "".equals(obj.trim());
	}
}
